require 'nl_gas_stations/scraper'

module NlGasStations

  class GasStations

    ##
    # Find gas stations by postal code, fuel type and an optional distance. The default distance is 5.
    # fuel_type must be one of the hash keys returned by #GasStations.fuel_types
    def self.find_stations(postal_code, fuel_type, distance = 5)
      distance = 5 unless [5, 10, 15, 25].include?(distance)
      fuel_type = self.fuel_types[fuel_type]
      Scraper.scrape({'postcode' => postal_code, 'plaats' => '', 'afstand' => distance, 'brandstof' => fuel_type, 'zoeken' => 'Zoeken'})
    end

    ##
    # Return the valid fuel types that can be search on with the #GasStations.find_stations method.
    # The hash keys must be used in the #GasStations.find_stations method.
    def self.fuel_types
      {diesel: 'Diesel', euro_95: 'Euro 95', lpg: 'LPG', cng: 'CNG'}
    end


  end
end